package com.trkj.property_controller;

import com.trkj.entity.RegionEntity;
import com.trkj.entity.UnitEntity;
import com.trkj.service.UnitService;
import com.trkj.vo.AjaxResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@CrossOrigin
public class unitController {
    @Autowired
    private UnitService unitService;

    @PostMapping("/selectUnit")
    public List<UnitEntity> selectUnit(@RequestBody UnitEntity unitEntity){
        log.info("selectUnit");
        return unitService.selectUnit(unitEntity);
    }
    @PostMapping("/AddUnit")
    public Boolean AddRegion(@RequestBody UnitEntity unitEntity){
        return unitService.AddUnit(unitEntity);
    }
    @DeleteMapping("/delUnit")
    public Boolean delRegion(@RequestParam("id") int id){
        return unitService.deleteUnit(id);
    }

    @PutMapping("/updateUnit")
    public Boolean updateRegion(@RequestBody UnitEntity unitEntity){
        return unitService.updateUnit(unitEntity);
    }
    //查询所有单元数量
    @PostMapping("/UnitList")
    public AjaxResponse UnitList(){
        return AjaxResponse.success(unitService.UnitList());
    }
}
